<template>
	<!-- <scroll-view :scroll-y="true" class="content" :style="{'top':navHeight+'px'}">
		<loading-page :loading="loading"></loading-page>
		<view v-if="!loading">
			<view>
				<mescroll-body ref="mescrollRef" :top="0" :down="downOption" :up="upOption" :bottom="0"
					@init="mescrollInit" @down="downCallback" @up="upCallback">
					<u-search @change="search" v-model="keyword" shape="round" bgColor="#FFFFFF" :showAction="false"></u-search>
					<view v-for="(item,index) in dataList" :key="index">
						<car-site-cell @click.native="cell_Click(item)" :data="item"></car-site-cell>
					</view>
					<empty :show="showEmpty"></empty>
				</mescroll-body>
			</view>
		</view>
	</scroll-view> -->
	<view>
		<u-search @change="search" v-model="keyword" shape="round" bgColor="#FFFFFF" :showAction="false"></u-search>
		<view v-for="(item,index) in dataList" :key="index" @click.stop="cell_Click(item)">
			<car-site-cell :data="item"></car-site-cell>
		</view>
		<empty :show="showEmpty"></empty>
	</view>
</template>

<script>
	import carSiteCell from '../components/carSiteCell.vue'
	import * as siteApi from '../../api/site/index.js'
	import empty from './@/components/empty.vue'
	import MescrollMixin from "@/components/mescroll-uni/components/mescroll-uni/mescroll-mixins.js"
	import mescrollBody from "@/components/mescroll-uni/components/mescroll-body/mescroll-body.vue"
	import {paging} from '@/mixins/paging.js'
	var globalData=getApp({allowDefault: true}).globalData
	export default{
		mixins:[paging,MescrollMixin],
		components:{carSiteCell,mescrollBody,empty},
		data(){
			return{
				navHeight:0,
				dataList: [],
				loading: true,
				keyword:'',
				query:{
					pageNum:1
				},
				complete:null,
				fail:null
			}
		},
		mounted() {
			this.getSiteList()
			this.navHeight=globalData.titleHeight;
		},
		methods:{
			search(value){
				this.query.pageNum = 1;
				this.dataList = [];
				this.keyword=value;
				this.getSiteList()
			},
			cell_Click(item){
				uni.navigateTo({
					url:'/pages/site/carSiteDetail?id='+item.id
				})
			},
			loadNext(num, complete,fail){
				this.query.pageNum = num
				this.complete=complete
				this.fail = fail
				this.getSiteList()
			},
			getSiteList() {
				siteApi.getChargingGroupList(1,this.keyword, this.query.pageNum).then((res) => {
					this.loading=false;
					this.complete(res.data.records.length,res.data.records.length<10?false:true)
					if (this.query.pageNum === 1) {
						this.dataList = []
					}
					this.dataList = this.dataList.concat(res.data.records)
					this.showEmpty=this.dataList.length==0?true:false
				}).catch((errMsg)=>{
					this.loading=false;
					this.fail()
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content{
		margin: 0rpx 30rpx 30rpx 30rpx;
		padding-top:20rpx;
		position: fixed;
		left:0rpx;
		right:0rpx;
		bottom:0rpx;
		top:0rpx;
		width:calc(100% - 60rpx);
	}
</style>
